package org.example.spring05.entity;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.Data;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

@Data
public class Person implements InitializingBean , DisposableBean {

    private Integer id;
    private String name;

    public Person() {
        System.out.println("Person 构造器");
    }

    public void init(){
        System.out.println("Person  初始化");
    }

    public void destroy(){
        System.out.println("销毁");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("初始化数据");
    }

    @PostConstruct
    public void postConstruct(){
        System.out.println("在构造器之后执行");
    }

    @PreDestroy
    public void preDestroy(){
        System.out.println("销毁之前执行");
    }
}
